package com.ybdz.scanner.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ybdz.scanner.R;
import com.ybdz.scanner.base.BaseAdapter;
import com.ybdz.scanner.bean.LuKuBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ClassName: luKuLiShiAdapter
 * @author: zhao
 * @Description: 查看入库历史的adapter
 * @date 2018/1/20 15:16
 */
public class luKuLiShiAdapter extends BaseAdapter<luKuLiShiAdapter.luKuLiShiViewHolder> {

    private final LayoutInflater inflater;
    private List<LuKuBean> mList ;
    private Context context;

    public luKuLiShiAdapter(Context context, List<LuKuBean> mList) {
        this.mList = mList;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public luKuLiShiViewHolder CreateChildViewHolder(ViewGroup parent, int viewType) {
        View view = this.inflater.inflate(R.layout.item_recycleview, parent, false);

        return new luKuLiShiViewHolder(view);
    }

    @Override
    public void bindViewHolder(luKuLiShiViewHolder holder, int position) {
        holder.mTvName.setText(String.valueOf(mList.get(mList.size()-position-1).getName()));
        holder.mTvWeight.setText(String.valueOf(mList.get(mList.size()-position-1).getWeight()));
        holder.mTvConformity.setText(String.valueOf(mList.get(mList.size()-position-1).getIsQualified()));
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }


    class luKuLiShiViewHolder extends BaseAdapter.BaseViewHolder{
        @BindView(R.id.tv_name)
        TextView mTvName;
        @BindView(R.id.tv_weight)
        TextView mTvWeight;
        @BindView(R.id.tv_conformity)
        TextView mTvConformity;

        luKuLiShiViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
